<template>
  <div class="vendor_box" v-loading="signalsRadio1.loading" element-loading-text="加载中...">
    <Totalarticles v-if="signalsRadio1.title.title != ''" />
    <div class="totalar" v-if="signalsRadio1.routerPush == 'details'">
      <div v-if="signalsRadio1.routerdetails == '3'">为您找到<span class="activeClor">{{ signalsRadio1.daochuCgstotals
          }}</span>家采购商</div>
    </div>
    <div style="min-height: 200px" v-if="signalsRadio1.total > 0">
      <div class="vendor" v-for="item in signalsRadio1.buyerLiss" :key="item">
        <div>
          <img width="60px" src="../../../../assets/newimg/gys.png" alt="" />
        </div>
        <div style="flex: 1; margin-left: 10px">
          <div class="vendor_cen">
            <div class="vendor_h" @click="gysClick(item.key)">
              <span v-html="item.key"></span>
            </div>
            <div>
              <span class="origin">最近采购 {{ timestamp(item.max_time?.value) }}</span><span class="origin">采购{{
    item?.doc_count }}次</span><span class="origin">采购总金额{{ money(item.color_sum_price?.value) }}</span>
            </div>
          </div>
          <div class="omission">
            <span style="color: #a9b1be">采购产品：</span>
            <span v-for="ele in item.field1Values.buckets" :key="ele"
              :class="{ resad: signalsRadio1.title.title == ele.key }">
              {{ ele.key }},</span>
          </div>
        </div>
      </div>
    </div>
    <Pagination ref="pagination" v-if="signalsRadio1.routerPush == 'search'" />
    <Paginations v-if="signalsRadio1.routerPush == 'details'" />
    <Vips v-if="signalsRadio1.buyerLiss.length >0"/>
      <div v-if="signalsRadio1.buyerLiss.length == 0" style="background-color: white; margin: 15px 0">
        <el-empty description="暂无数据" />
      </div>
    </div>
  </template>

<script setup>
import { useRadio1Store } from "@/pain/search/search";
import Totalarticles from "../totalarticles/index.vue";
import Pagination from "@/components/pagination/index.vue";
import Paginations from "@/components/daochuPages/index.vue";
import Vips from "@/components/vipts/index.vue";
import { timestamp, money } from "@/utils/index";
import { useCounterStore } from "@/pain/login/login";
import { useRouter } from "vue-router";
const router = useRouter();
let signalsRadio1 = useRadio1Store();
let useRouters = useCounterStore()
const cgsshuju = () => {
  if (signalsRadio1.routerPush == "details") {
    let daochu = JSON.parse(localStorage.getItem("daochu"));
    const ditu = JSON.parse(localStorage.getItem("ditu"));
    let list = {
      ...daochu,
      ...ditu,
    };
    signalsRadio1.T_getbuyers(list);
  }
};
cgsshuju();
// const pagination = ref(null);
// pagination.value.currentPage
// pagination.value.pageSize
console.log(signalsRadio1.title.title);
// signalsRadio1.id = router.currentRoute.value.query.id
const gysClick = (data) => {
  if (!localStorage.getItem("token")) {
    return (useRouters.uselogin = true);
  }
  if (signalsRadio1.routerPush == "search") {
    const href = router.resolve({
      path: "/disposition",
      query: {
        id: signalsRadio1.id,
        name: data.replace(/<[^>]+>/g, ""),
      },
    });
    window.open(href.href, "_blank");
  }
};
</script>

<style lang="scss" scoped>
.totalar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  padding: 0 20px;
  background-color: #fff;

  .totalar_right {
    display: flex;
  }

  .daochu1 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 30px;
    margin-left: 15px;
    font-size: 14px;
    border: 1px solid #6675FF;
    border-radius: 4px;
    color: #6675FF;
  }
}

.resad {
  color: red;
}

.origin {
  height: 20px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #fe8d03;
  color: #fff;
  margin-left: 10px;
  font-size: 12px;
}

.vendor_box {
  background-color: #fff;

  //
  .vendor {
    display: flex;
    padding: 20px;
    border-bottom: 1px solid #eeeeee;
    cursor: pointer;

    &:hover {
      background-color: #eeeeee;
    }
  }

  .vendor_cen {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;

    .vendor_h {
      margin-top: 5px;
      font-size: 16px;
      color: #333333;
    }
  }

  .omission {
    width: 1090px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
    font-size: 14px;
  }
}
</style>
